let v = new Vue({
    el: '#app',
    data: {
        hot:[],     //热门商品
        pageInfo:{}, //分页数据
        keywords:{
            title:''
        }
    },
    methods: {
        initProductList:function (pageNum,pageSize) {
            this.keywords.title = localStorage.getItem("title");
            if (this.keywords.title === null){
                this.keywords.title = '';
            }
            axios.post(`goods/initProductList/${pageNum}/${pageSize}`,this.keywords)
                .then(rsp=>{
                    if (rsp.data.flag){
                        this.pageInfo = rsp.data.data.pageInfo;
                        this.hot = rsp.data.data.hot;
                        this.keywords.title = localStorage.setItem("title","");
                    }
                })
                .catch(error=>{
                    layer.msg(error.message);
                });
        },
        toGoodsDetail:function (id) {
             localStorage.setItem("aid",id);
        }
    },
    created: function () {
        this.initProductList(1,16);
    }
});